package control;

import java.awt.FileDialog;
import java.util.Set;

import model.Sheet;
import model.XLPrintStream;
import model.XLPrintStream;
import view.Gui;
import view.StatusArea;

class SaveMenuItem extends FileMenuItem {
    public SaveMenuItem(Gui gui, StatusArea statusArea) {
        super(gui, statusArea, "Save");
        action = FileDialog.SAVE;
    }

    public void action(String name) {
        try {
        	Sheet sheet = gui.getSheet();
            XLPrintStream printStream = new XLPrintStream(name);
            printStream.save(sheet.getMap().entrySet());
        } catch (Exception e) {
            statusArea.setText(e.getMessage());
        }
    }
}